#pragma once
#include <string>
#include <sysinfoapi.h>

using namespace std;

/// Get Number of Processors
inline static int GetNumOfProcessors()
{
	SYSTEM_INFO SI;
	GetSystemInfo(&SI);
	return SI.dwNumberOfProcessors;
}

inline BOOL __stdcall EnumWindowsFunc(HWND hwnd, LPARAM l)
{
	DWORD pid;
	DWORD tid = GetWindowThreadProcessId(hwnd,&pid);
	static int i = 0;
	if (pid == l)
	{
		i++;
		pid++;
		return false;
	}
	i++;
	return TRUE;
}
inline static HWND GetHwndByPID(DWORD dwPid)
{
//	4680 3084 5320

//	DWORD dwro = GetProcessId(dwPid);
	HWND hwnd = GetTopWindow(0);
	while (hwnd)
	{
		DWORD pid;
		
		DWORD tid = GetWindowThreadProcessId(hwnd,&pid);
		if(pid == dwPid)
		{
	//		return hwnd;
		}
		hwnd = GetNextWindow(hwnd,GW_HWNDNEXT);
	}

	dwPid;
//	WaitForInputIdle(dwPid,INFINITE);
	EnumWindows(EnumWindowsFunc,dwPid);
	
	return NULL;
}